(function () {  
    let seckill_swiper = document.querySelector('.seckill_swiper'),
    wrapper = seckill_swiper.querySelector('.swiper_box'),
    slides = Array.from(wrapper.querySelectorAll('.swiper_item'))
    
    let count = 2,
    step = 0,
    W = seckill_swiper.clientWidth

    wrapper.appendChild(slides[0].cloneNode(true))
    wrapper.appendChild(slides[1].cloneNode(true))
    wrapper.appendChild(slides[2].cloneNode(true))
    wrapper.appendChild(slides[3].cloneNode(true))
    count++
    wrapper.style.width = `${count*W}px`

    wrapper.style.transform = `translateX${-step*W}px`
    

    const moveRight = function moveRight() {  
        step++
        if(step>= count){
            wrapper.style.transitionDuration = '0s'
            wrapper.style.transform =  `translateX(0)`
            step = 1
            wrapper.offsetWidth
        }
        wrapper.style.transitionDuration = '.3s'
        wrapper.style.transform = `translateX(${-step*W}px)`
    }
    const moveLeft = function moveLeft() {  
        step--
        if(step<0){
            wrapper.style.transitionDuration = '0s'
            wrapper.style.transform = `translateX(${-(count-1)*W}px)`
            step = count - 2
            wrapper.offsetWidth
        }
        wrapper.style.transitionDuration = '.3s'
        wrapper.style.transform = `translateX(${-step*W}px)`
    }

   seckill_swiper.onclick = utils.throttle(function (e) {  
    let tagName = e.target.tagName
     if(tagName === 'A'){
        let dt = e.target.getAttribute('data-type')
        dt ===  'btn-prev' ? moveLeft() : moveRight()
     }
   })
})()

